#ifndef CREOLE_REGEX
#define CREOLE_REGEX

#include <iostream>
#include <cstdlib>
#include <string>

#include "regex_base.h"
#include "result.h"
#include "term.h"
#include "alt.h"
#include "mt0.h"
#include "by_ref.h"

class regex : public regex_base
{
     regex_base* what;
     public:
     regex() : what(0) {}
     regex& operator=(const regex& r)
     {
          what = r.what->copy();
          return *this;
     }
     regex(const regex_base& r) : what(r.copy()) {}
     regex_base* copy() const
     {
          regex* p = new regex;
          p->what = what->copy();
          return p;
     }
     ~regex() { if(what){delete what;} }
     match_result match(const std::string& s) const
     {
          if(what==0)
          {
               return match_result(false,0);
          }
          else
          {
               return what->match(s);
          }
     }
};

#endif
